package com.gy.service.impl;

import com.aaa.entity.OrderBackfee;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gy.mapper.OrderBackFeeMapper;
import com.gy.service.OrderBackfeeService;
import com.gy.vo.ChargeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @Author GaoYa
 * @Date 2023/3/24 17:05
 * @Version 1.5
 */
@Service
public class OrderBackfeeServiceImpl implements OrderBackfeeService {
    @Autowired(required = false)
    private OrderBackFeeMapper orderBackfeeDao;

    /**
     * 退费查询分页和模糊查询
     * @param current
     * @param size
     * @param chargeVo
     * @return
     */
    @Override
    public Result<IPage<OrderBackfee>> findAll(Integer current, Integer size, ChargeVo chargeVo) {
        IPage<OrderBackfee> page = new Page<>(current,size);
        QueryWrapper<OrderBackfee> queryWrap = new QueryWrapper();
        if (StringUtils.hasText(chargeVo.getPatientName())){
            queryWrap.eq("patient_name",chargeVo.getPatientName());
        }
        if (StringUtils.hasText(chargeVo.getRegId())){
            queryWrap.eq("reg_id",chargeVo.getRegId());
        }
        IPage<OrderBackfee> page1 = orderBackfeeDao.selectPage(page, queryWrap);
        return new Result<>(2000,"查询分页成功",page1);
    }


}
